#!/bin/ksh

# $Id: radiotune,v 1.31 2008/07/27 22:12:29 artis Exp $

readonly _radiorc=${HOME}/.radiorc
readonly _designation=$(egrep -v '^$|^#' $_radiorc | awk -F '|' '{print $1}')
readonly PS3="Tune in: "
readonly IFS="

"

trap 'pkill -U $USER mplayer;printf "\033[0m"' INT
pkill -u $USER mplayer

printf "\033[1;32;40m"

select _station in $_designation; do
	readonly _wavelenght=$(grep $_station $_radiorc | awk -F '|' '{print $2}')
	printf "\033[1;36;40m"
	printf "\t\tTuning to $_station station"
	printf "\033[0m"
	exec mplayer -cache 32 "$_wavelenght" < /dev/null > /dev/null 2>&1 &
	break
done
